# Maintainer: Balló György <ballogyor+arch at gmail dot com>
# Contributor: Lex Black <autumn-wind@web.de>
# Contributor: Alexander F Rødseth <xyproto@archlinux.org>
# Contributor: Thomas S Hatch <thatch45@gmail.com>
# Contributor: Corrado 'bardo' Primier <corrado.primier@mail.polimi.it>
# Contributor: Jochem Kossen <j.kossen@home.nl>
# Contributor: Daniel J Griffiths <ghost1227@archlinux.us>

pkgname=scite
pkgver=5.3.5
pkgrel=1
pkgdesc='Editor with facilities for building and running programs'
arch=('loong64' 'x86_64')
url='https://www.scintilla.org/SciTE.html'
license=('custom:HPND')
depends=('gtk3')
backup=('usr/share/scite/SciTEGlobal.properties')
source=("https://www.scintilla.org/${pkgname}${pkgver//./}.tgz"
        'SciTE.appdata.xml')
sha256sums=('a6527831ef8d658697bca30638149884f9d0afb3f748c86f5d27ed8b0bd1aa6e'
            'cecf3f2f86cd05541e4c87064244f098904d5aed535f77244977e22cede7c842')

prepare() {
  sed -i 's/xdg-open/gio open/' scite/src/*.properties
  sed -i 's|pixmapdir=$(datadir)/pixmaps|pixmapdir=$(datadir)/icons/hicolor/48x48/apps|
          s|pixmapdir)/Sci48M.png|pixmapdir)/SciTE.png|' scite/gtk/makefile
  sed -i 's/Sci48M/SciTE/' scite/gtk/{SciTEGTK.cxx,SciTE.desktop}
}

build() {
  make -C lexilla/src
  make -C scintilla/gtk GTK3=1
  make -C scite/gtk GTK3=1
}

package() {
  make -C scite/gtk DESTDIR="$pkgdir" GTK3=1 install
  install -Dm644 scite/License.txt "$pkgdir/usr/share/licenses/$pkgname/License.txt"
  install -Dm644 SciTE.appdata.xml "$pkgdir/usr/share/metainfo/SciTE.appdata.xml"
  ln -sf /usr/bin/SciTE "$pkgdir/usr/bin/scite"
}
